<template>
	<view class="content">
		<view class="logintitle">
			仿微信
		</view>
		<view class="loginform">
			<view class="loginlabel">
				账号:
			</view>
			<view class="loginkuang">
				<input type="text" v-model="loginCode" placeholder="请输入账号" />
			</view>
			<view class="loginlabel">
				密码:
			</view>
			<view class="loginkuang">
				<input type="password" v-model="passWord" placeholder="请输入密码" />
			</view>
			<view class="loginbutton" @click="login">
				登录
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				loginCode: "",
				passWord: ""
			}
		},
		methods: {
			async login() {
				if (this.loginCode == '' || this.passWord == '') {
					uni.showToast({
						icon: "error",
						title: "请输入用户名或密码"
					})
				} else {
					const res = await this.$myRequest({
						url: "/login",
						method: "post",
						data: {
							username: this.loginCode,
							password: this.passWord,
							repassword: ""

						},
						// header:{
						// 	token:false
						// }
					})
					console.log(res);

					uni.setStorageSync("token", res.data.data.token)
										uni.setStorageSync("user_id", res.data.data.id)
					uni.setStorageSync("user", JSON.stringify(res.data.data))
					uni.switchTab({
						url:"/pages/index/index"
					})
				}

			}
		}
	}
</script>

<style>
	.loginbutton {
		width: 100%;
		height: 49px;
		line-height: 49px;
		text-align: center;
		color: #ffffff;
		background: #1369eb;
		border-radius: 4px;
	}

	.loginkuang input {
		height: 100%;
		padding-left: 11px;
		box-sizing: border-box;
		line-height: 49px;

	}

	.loginkuang {
		width: 100%;
		height: 49px;
		background: #ffffff;
		margin-top: 10px;
		margin-bottom: 16px;
		border-radius: 4px;
		box-shadow: 0px 1.5px 5px 0px #f1f2f6;
	}

	.loginlabel {
		width: 100%;
		height: auto;
		padding-left: 10px;
		box-sizing: border-box;


		font-size: 15px;
		font-family: Source Han Sans SC, Source Han Sans SC-Regular;
		font-weight: 400;
		text-align: left;
		color: #a3a3a3;
	}

	.content {
		width: 100%;
		height: 100%;
		background: url("../../static/loginmb.png") no-repeat;
		background-size: 100% 100%;
		border: 0.01px solid transparent;
		padding: 0px 20px;
		box-sizing: border-box;
	}

	.logintitle {
		width: 100%;

		font-size: 21px;
		font-family: FZZhengHeiS-EB-GB, FZZhengHeiS-EB-GB-Regular;
		font-weight: bold;
		text-align: center;
		color: #4877e7;
		margin-top: 108px;

		letter-spacing: 0.63px;
	}

	.loginform {
		width: 100%;
		height: auto;
		background: #ffffff;
		padding: 20px 17px;
		box-sizing: border-box;
		border-radius: 12px;
		margin-top: 24px;
	}
</style>